#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

#include "errlog.h"

#define NUM_THREADS 16

pthread_t threads[NUM_THREADS];

void* job(void* null)
{
	for(int i = 250; i>0; i--)
	{
		usleep(rand()%100);
		errlog(LOG_NOERR, "NOERR\n");
		errlog(LOG_WARNG, "WARNG\n");
		errlog(LOG_ERROR, "ERROR\n");
	}
	pthread_exit(NULL);
}

int main()
{
	errlog_init(LOG_WARNG);
	int i;
	for(i = 0; i < NUM_THREADS; i++)
		if(pthread_create(&threads[i], NULL, job, NULL) < 0)
			exit(-1);
			
	errlog(LOG_NOERR, "MT: NOERR\n");
	errlog(LOG_WARNG, "MT: WARNG\n");
	errlog(LOG_ERROR, "MT: ERROR\n");

	void * buf;
	for(i = 0; i < NUM_THREADS; i++)
		pthread_join(threads[i],&buf);
	errlog_deinit();
	return 0;
}
